/*
* $Id: SectionItem.cpp 54 2010-03-09 20:16:01Z volok-aleksej@yandex.ru $
*
* Copyright 2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "SectionItem.h"

CSectionItem::CSectionItem(const std::tstring& strName, int nId)
: CEditorItem(strName, nId){
	m_pFont = CCommonFunction::GetFont(_T("Book Antiqua"), m_sizefont, true, true, true);
}
CSectionItem::~CSectionItem(){
	m_pFont->DeleteObject();
	delete m_pFont;
}

void CSectionItem::Paint(CDC* dc){
	HGDIOBJ oldObj = dc->SelectObject(m_pFont->m_hObject);
	dc->SetBkMode(TRANSPARENT);
	COLORREF colorText = dc->GetTextColor();
	dc->SetTextColor(RGB(0, 0, 0));
	dc->DrawText(m_strName.c_str(), CRect(m_point, m_size), DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	dc->SetTextColor(colorText);
	dc->SelectObject(oldObj);
}
void CSectionItem::Resize(){
	std::vector<std::tstring> aString = CStringFunction::GetStringArray(m_strName, _T("\n"));
	m_size.cy = (int)aString.size() * m_sizefont + 5;
}
